package ui.component
{
	import flash.display.Bitmap;
	import flash.display.BitmapData;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.media.Camera;
	import flash.text.TextField;
	import flash.utils.Dictionary;
	
	public class RobotInfo extends Sprite
	{
		private var _hp:ContrastValue;
		private var _act:ContrastValue;
		private var _def:ContrastValue;
		private var _speed:ContrastValue;
		
		private var _back:Bitmap;
		/////////////////////////////////////////////////////
		public function get speed():ContrastValue
		{
			return _speed;
		}

		public function get def():ContrastValue
		{
			return _def;
		}

		public function get act():ContrastValue
		{
			return _act;
		}

		public function get hp():ContrastValue
		{
			return _hp;
		}
		
		/////////////////////////////////////////////////////
		public function RobotInfo(BitmapDatas:Dictionary=null)
		{
			var bkBmd:BitmapData = new BitmapData(1,22,false,0x555555);
			_back = new Bitmap(bkBmd);
			addChild(_back);
			
			_hp = new ContrastValue("装甲：",BitmapDatas);
			_act = new ContrastValue("攻击力：",BitmapDatas);
			_def = new ContrastValue("防御力：",BitmapDatas);
			_speed = new ContrastValue("速度：",BitmapDatas);
			
			_hp.x = 20;
			_act.x = 135;
			_def.x = 270;
			_speed.x = 400;
			
			addChild(_hp);
			addChild(_act);
			addChild(_def);
			addChild(_speed);
			
			addEventListener(Event.ADDED_TO_STAGE,onAdded);
			addEventListener(Event.REMOVED_FROM_STAGE,onRemoved);
		}
		

		private function onAdded(e:Event):void
		{
			x = 150;
			_back.scaleX = stage.stageWidth-x;
			
			addEventListener(Event.RESIZE,onResize);
		}
		
		private function onResize(e:Event):void
		{
			_back.scaleX = stage.stageWidth-x;
		}
		
		private function onRemoved(e:Event):void
		{
			removeEventListener(Event.ADDED_TO_STAGE,onAdded);
			removeEventListener(Event.REMOVED_FROM_STAGE,onRemoved);
			removeEventListener(Event.RESIZE,onResize);
		}
	}
}